package com.mic.dao;

import com.mic.pojo.*;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface UserMapper {
    int addArticle(Article article);
    int deleteArticle(Integer articleId);
    int updateArticle(Article article);

    //List<Article> queryAllArticleByUserId(@Param("userId") Integer userId);//找某用户的所有博文

    List<Article> queryTopFourArticles();//找出TOP4

    List<Article> queryFiveUserFavoriteArticlesByUserId(@Param("userId")Integer userId);//五个收藏

    List<Article> queryAllUserArticlesByUserId(@Param("userId")Integer userId);//通过userId查所有博文

    List<User> queryAllUserSubscriptionById(@Param("userId")Integer userId);//所有的订阅

    List<Article> queryAllUserFavoriteArticlesByUserId (@Param("userId")Integer userId);//所有的收藏

    List<Article> queryAllArticlesByTime (@Param("userId")Integer userId);//按时间展示所有的文章

    List<User> searchAllRelativeUsersByKeyEqualsUsername (@Param("key")String key);//根据key查询到所有的Users(key和username相似)

    List<Article> searchAllRelativeArticlesByKeyEqualsTitleOrInShort (@Param("key")String key);//根据key查询到所有的文章(key和title or inShort相似)

    Article searchArticleByCertainArticleId (@Param("certainArticleId")Integer certainArticleId);//根据certainArticleId查询到Article(精准)

    User searchUserByCertainUserId(@Param("certainUserId")Integer certainUserId);
    int updatePersonalInfo(User user);//用户修改个人信息

    //like
    Article queryArticleByArticleId(@Param("articleId") Integer articleId);

    //comment
    int addComment(Comment comment);
    List<Comment> queryAllCommentsByArticleId(@Param("articleId") Integer articleId);
    int deleteComment(@Param("commentId") Integer commentId);


    //subscription
    int addSubscription(UserSubscription userSubscription);
    List<UserSubscription> queryAllUserSubscriptionByUserId(@Param("userId") Integer userId);
    int cancelSubscription(UserSubscription userSubscription);

    //favorite
    int addFavorite(UserFavorite userFavorite);
    List<UserFavorite> queryAllUserFavoriteByUserId(@Param("userId") Integer userId);
    int cancelFavorite(UserFavorite userFavorite);

    //热门博主写出了获赞最多的博文
    Article hotUser();
    List<Article> decsSixArticlesByLikes(Integer userId);

    //发布博文
    int writeAnArticle(Article article);
    //删除博文
    int deleteAnArticle(@Param("articleId") Integer articleId);

    //删除评论
    int deleteACommentId(@Param("commentId") Integer commentId);
    Comment getCommentById(@Param("commentId") Integer commentId);

}
